package service

import (
	"errors"
	"gin_wuwen_back/tool"
	"github.com/gin-gonic/gin"
	qrcode "github.com/skip2/go-qrcode"
	"log"
	"net/http"
	"strconv"
)
/*
  @Description:
  @receiver tmp
  @param c
  @return ans
  @return err
*/
func (tmp *Service_func) Qcord(c *gin.Context) (ans []byte, err error) {
	id, ok := c.Get("Userid")
	it := id.(int64)
	uid := strconv.FormatInt(it, 10)
	if !ok {
		err = errors.New("获取userid时失败")
		return nil, err
	}
	Url := "http://" + tool.Confing.AppIP + ":" +"/api/Talk"+ uid
	log.Println(Url)
	return qrcode.Encode(Url, qrcode.Medium, 256)

}

func (tmp *Service_func) TalkWithOthers(c *gin.Context, myuid int, uid int) error {
	//1.将自己的id和对方的id全部返回过去
	data := make(map[string]int)
	data["myuid"] = myuid
	data["uid"] = uid

	c.JSON(http.StatusOK, gin.H{
		"code": 1,
		"data": data,
		"msg":  "双方的id返回成功",
	})
	return nil

}
